package org.phalanx.client.menus;

import java.awt.Color;

import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import org.phalanx.client.mapeditor.PhalanxMapEditorPanel;

public class DisplayMenuPopUp extends JPopupMenu {
	private JCheckBoxMenuItem drawGridLines;
	private JCheckBoxMenuItem drawBuildPoints;
	private JMenuItem zoomIn;
	private JMenuItem zoomOut;
	private PhalanxMapEditorPanel masterPanel;
	private DisplayMenuAction menuActions;
	
	public DisplayMenuPopUp(PhalanxMapEditorPanel masterPanel){
		this.masterPanel = masterPanel;
		initializeMenu();
		setUpMenuItems();
		addComponents();
	}
	
	private void initializeMenu(){
		this.setBackground(Color.white);
		this.setForeground(Color.black);
		
		menuActions = new DisplayMenuAction(masterPanel);
	}
	
	private void setUpMenuItems(){
		drawGridLines = new JCheckBoxMenuItem();
		drawGridLines.setForeground(Color.black);
		drawGridLines.setBackground(Color.white);
		drawGridLines.setText("Draw GridLines");
		drawGridLines.setName("drawgridlines");
		drawGridLines.setState(true);
		
		drawBuildPoints = new JCheckBoxMenuItem();
		drawBuildPoints.setForeground(Color.black);
		drawBuildPoints.setBackground(Color.white);
		drawBuildPoints.setText("Show Build Points");
		drawBuildPoints.setName("drawbuildpoints");
		drawBuildPoints.setState(true);
		
		zoomIn = createDefaultMenuItem();
		zoomIn.setText("+ Zoom In");
		zoomIn.setName("zoomin");
		
		zoomOut = createDefaultMenuItem();
		zoomOut.setText("- Zoom Out");
		zoomOut.setName("zoomout");
		
		drawGridLines.addActionListener(menuActions);
		zoomIn.addActionListener(menuActions);
		zoomOut.addActionListener(menuActions);
		drawBuildPoints.addActionListener(menuActions);
	}
	
	private void addComponents(){
		this.add(drawGridLines);
		this.add(drawBuildPoints);
		this.add(zoomIn);
		this.add(zoomOut);
	}
	
	private JMenuItem createDefaultMenuItem(){
		JMenuItem tempMenuItem = new JMenuItem();
		tempMenuItem.setForeground(Color.black);
		tempMenuItem.setBackground(Color.white);
		
		return tempMenuItem;
	}
}
